//
//  YAStatus.swift
//  KeepCliming
//
//  Created by 鱼龙之梦 on 15/9/6.
//  Copyright © 2015年 panyanzhi. All rights reserved.
//

import UIKit

class YAStatus: NSObject {
    var created_at:String?
    var id:Int = 0
    var text:String?
    /// 配图字典数组 key = thumbnail_pic
    var pic_urls:[[String:String]]?
 /// 微博来源
    var source:String?{
        didSet{
            source = source?.href()?.text
        }
    }
    var user:YAUser?
    //转发微博
    var retweeted_status:YAStatus?
     //MARK:--- 字典构造函数
    init(dict:[String:AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
     //MARK:--- 排除未知键值
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        //
    }
     //MARK:--- 处理字典中含有数组的字段
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
            user = YAUser(dict: value as! [String:AnyObject])
            return
        }
        if key ==  "retweeted_status" {
            retweeted_status = YAStatus (dict: value as! [String:AnyObject])
            return
        }
        super.setValue(value, forKey: key)
    }
     //MARK:--- 自定义打印该对象的方法
    override var description:String{
        let keys = ["created_at","id","text","source","user","pic_urls","retweeted_status"]
        return dictionaryWithValuesForKeys(keys).description
    }
}
